package com.yb.guigu.pick.core.publisher;

import com.yb.guigu.pick.core.bean.event.GuiguPickEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.lang.NonNull;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/9 15:37
 * FileName: GuiguPickEventPublisher
 * Description:
 */
public class GuiguPickEventPublisher implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher applicationEventPublisher;
    @Override
    public void setApplicationEventPublisher(@NonNull ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher=applicationEventPublisher;
    }



    public <T extends GuiguPickEvent<?>> void publish(T event){
        applicationEventPublisher.publishEvent(event);
    }


    public <T> void publish(Object source,T data){
        applicationEventPublisher.publishEvent(new GuiguPickEvent<>(source,data));
    }
}
